x86emul/test: wrap libc functions with FPU save/restore code
authorJan Beulich <JBeulich@suse.com>
Fri, 9 Mar 2018 13:47:21 +0000 (06:47 -0700)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 9 Mar 2018 15:42:23 +0000 (15:42 +0000)
commit715bdd0e471f72a993fbd1ec272801d3bdddc4b4
tree8557264cadcfb94b7a6823ab2edb9b8aa6269711
parent1a81958928f07b45f170427647876ba5d49f9fb9
x86emul/test: wrap libc functions with FPU save/restore code

Currently with the native tool chain on Debian Jessie ./test_x86_emulator
yields:

  Testing AVX2 256bit single native execution...okay
  Testing AVX2 256bit single 64-bit code sequence...[line 933] failed!

The bug is that libc's memcpy() in read() uses %xmm8 (specifically, in
__memcpy_sse2_unaligned()), which corrupts %ymm8 behind the back of the AVX2
test code.

Introduce wrappers (and machinery to forward calls to those wrappers)
saving/restoring FPU state around certain library calls.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-and-tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/fuzz/x86_instruction_emulator/Makefile
tools/tests/x86_emulator/Makefile
tools/tests/x86_emulator/wrappers.c [new file with mode: 0644]
tools/tests/x86_emulator/x86-emulate.h